<?php

/**
 * @author HungNQ
 */
class Utility
{

    public static function getBeginDateOfMonth($date)
    {
        list($month, $year) = self::getMonthYear($date);
        //first day in month
        $begin = mktime(0, 0, 0, $month, 01, $year);
        return date('d/m/Y', $begin);
    }

    public static function getEndDateOfMonth($date)
    {
        list($month, $year) = self::getMonthYear($date);
        $end = mktime(0, 0, 0, $month + 1, 0, $year);
        return date('d/m/Y', $end);
    }

    public static function getMonthYear($date)
    {
        $month = date('m', $date);
        $year = date('Y', $date);
        return array($month, $year);
    }

    //put your code here

    public static function getDayInWeek($day, $strdate)
    {
        $date = strtotime($strdate);
        $month = date('m', $date);
        $year = date('Y', $date);
        //first day in month
        $timestamp = mktime(0, 0, 0, $month, $day, $year);

        $dayInWeek = date('w', $timestamp);

        $dayText = "";
        switch ($dayInWeek) {
            case 0:
                $dayText = 'CN';
                break;
            case 1:
                $dayText = 'T2';
                break;
            case 2:
                $dayText = 'T3';
                break;
            case 3:
                $dayText = 'T4';
                break;
            case 4:
                $dayText = 'T5';
                break;
            case 5:
                $dayText = 'T6';
                break;
            case 6:
                $dayText = 'T7';
                break;
        }
        return $dayText;
    }

}
